package com.itheima.test1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) throws IOException {
        //服务器
        //多次接收数据，并打印
        //创建服务器对象并绑定端口
        ServerSocket ss = new ServerSocket(8888);
        //等待连接并返回一个连接通道
        Socket socket = ss.accept();
        System.out.println("连接成功");
        //获取输入流
        InputStreamReader isr = new InputStreamReader(socket.getInputStream());
        BufferedReader br = new BufferedReader(isr);
        //接收数据
        String s;
        while ((s = br.readLine()) != null) {
            if ("886".equals(s)) {
                break;
            }
            System.out.println(s);
        }
        ss.close();
    }
}
